import java.sql.*;

public class JdbcUtil {
    private static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
    private static final String DATABASE_URL = "jdbc:mysql://localhost:3306/";
    private static final String USERNAME = "root";
    private static final String PASSWORD = "root";
    //初始化数据库连接
    public static Connection getConnection() {
        try{
            //加载数据库驱动类
            Class.forName(JDBC_DRIVER);
            //建立连接
            return DriverManager.getConnection(DATABASE_URL,USERNAME,PASSWORD);
        }catch(ClassNotFoundException | SQLException e){
            throw new RuntimeException("获取数据库连接失败",e);
        }
    }
    //关闭资源
    public static void closeResoutces(Connection conn, PreparedStatement pst, ResultSet rs){

    }
}
